package thesis.bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

@ManagedBean
@RequestScoped
public class VerifyLoggedBean {

	private String message;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public VerifyLoggedBean() {
		this.verify();
	}

	public void verify() {
		try {
			HttpSession session = (HttpSession) FacesContext
					.getCurrentInstance().getExternalContext().getSession(true);
			UserBean userBean = (UserBean) session.getAttribute("user");
			if (userBean.loggedIn == false) {
				FacesContext.getCurrentInstance().getExternalContext()
						.redirect("login.jsf");
			}

		} catch (Exception e) {
		}
	}
}
